<?php

require FCPATH . '/application/controllers/frontend.php';

class About extends Frontend {

	public function __construct() {
		parent::__construct();
	}

	public function index() {
		$this->load->model(array('about_model', 'slide_show_model'));
		$this->load_css('frontend_about_index');
		$this->load_js('frontend_about_index');

		$lang = $this->get_language();
		$id = intval($this->uri->segment(3, 1));

		$columns = array(
			array('title_' . $lang, 'title'),
			array('content_' . $lang, 'content')
		);
		$conditions = array(array('where', 'id', $id));
		$abouts = $this->about_model->records($columns, $conditions);
		if (count($abouts) > 0) {
			$about = $abouts[0];
		} else {
			die('404');
		}

		$columns = array(
			'link', array('description_' . $lang, 'description'), array('n.name', 'image_name')
		);
		$conditions = array(
			array('where', 'type', 2),
			array('where', 'parent', $id)
		);
		$slide_shows = $this->slide_show_model->records($columns, $conditions);

		$this->rend('about_index', array(
			'about' => $about,
			'slide_shows' => $slide_shows,
			'menus' => array('aim_and_purpose', 'excellence_and_awards', 'history', 'infrastructures', 'location'),
			'index' => $id - 1,
			'id' => $id
		));
	}

}